// 汽车，struct
package structs

import "fmt"

type Car struct {
	name string
}

func (c *Car) SetName(carName string) error {
	if len(carName) > 10 {
		return SetNameError(carName)
	}

	c.name = carName
	return nil
}

func (c *Car) Name() string {
	return c.name
}

func (c Car) String() string {
	return fmt.Sprintf("i am a car, name is %s", c.name)
}

func (c Car) RunWithSpeed(speed float64) {
	fmt.Printf("i am a car, name is %s, run with speed %.2f\n", c.name, speed)
}
